#ifndef TEST_RSA_H
#define TEST_RSA_H

#include <bsl_err.h>
#include <bsl_sal.h>
#include <crypt_algid.h>
#include <crypt_eal_pkey.h>
#include <crypt_eal_provider.h>
#include <crypt_errno.h>
#include <crypt_rsa.h>
#include <crypt_params_key.h>

#include <setjmp.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

#define TMP_BUFF_LEN 2048

#define RSA_MAX_KEYLEN 2048
#define RSA_MIN_KEYLEN 128

#define MAX_PARAM_LEN      2048
#define MAX_CIPHERTEXT_LEN 2048

#define PUB_EXP                 3
#define KEYLEN_IN_BYTES(keyLen) ((keyLen) >> 3)

typedef struct {
    char *n;
    char *e;
    char *d;
    int32_t hashId;
    char *in;
    char *out;
} CRYPT_RSA_Test;

typedef struct {
    int32_t hashId;
    char *n;
    char *e;
    char *d;
    char *in;
    char *out;
    char *salt;
    int32_t saltLen;
} CRYPT_RSA_TestWithSalt;

void SetRsaPara(CRYPT_EAL_PkeyPara *para, uint8_t *e, uint32_t eLen, uint32_t bits)
{
    para->id = CRYPT_PKEY_RSA;
    para->para.rsaPara.e = e;
    para->para.rsaPara.eLen = eLen;
    para->para.rsaPara.bits = bits;
}

void SetRsaPubKey(CRYPT_EAL_PkeyPub *pubKey, uint8_t *n, uint32_t nLen, uint8_t *e, uint32_t eLen)
{
    pubKey->id = CRYPT_PKEY_RSA;
    pubKey->key.rsaPub.n = n;
    pubKey->key.rsaPub.nLen = nLen;
    pubKey->key.rsaPub.e = e;
    pubKey->key.rsaPub.eLen = eLen;
}

void SetRsaPrvKey(CRYPT_EAL_PkeyPrv *prvKey, uint8_t *n, uint32_t nLen, uint8_t *d, uint32_t dLen)
{
    prvKey->id = CRYPT_PKEY_RSA;
    prvKey->key.rsaPrv.n = n;
    prvKey->key.rsaPrv.nLen = nLen;
    prvKey->key.rsaPrv.d = d;
    prvKey->key.rsaPrv.dLen = dLen;
}

#endif